package com.first.agent.web.controller;
/**
 *财务类型增加功能实现的Controller层
 */
import com.alibaba.fastjson.JSONObject;
import com.first.agent.common.R;
import com.first.agent.service.FinanceTypeService;
import com.first.agent.service.impl.FinanceTypeServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;


@WebServlet("/finance_type/add")
public class AddFinance_typeServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取前端传过来的内容
            String finance_type=req.getParameter("finance_type");
            String fi_state=req.getParameter("fi_state");
            FinanceTypeService financeTypeService=new FinanceTypeServiceImpl();//调用service层，进行数据响应
            R r=financeTypeService.typeAdd(finance_type,Integer.parseInt(fi_state));//将响应结果存到R里
        //对页面进行数据响应
            resp.setContentType("application/json;charset=utf-8");
            PrintWriter pw=resp.getWriter();
            pw.write(JSONObject.toJSONString(r));
            pw.flush();
            pw.close();
    }
}
